﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for EmpClass
/// </summary>
public class EmpClass:BaseClass
{
    public static int AddEmp(User user)
    {
        string query = String.Format("insert into EMPLOYEES values('{0}','{1}','{2}','{3}','{4}','{5}')"
            , user.ID, user.FName, user.SName, user.LName, user.Job, user.Center);
        return RunDML(query);
    }
    public static int UpdateEmp(User user)
    {
        string query = String.Format("update EMPLOYEES set ID='{0}' ,FNAME='{1}',SNAME='{2}',LNAME='{3}',JOB='{4}',CENTER='{5}' where ID='{0}'"
            , user.ID, user.FName, user.SName, user.LName, user.Job, user.Center);
        return RunDML(query);
    }
    public static int DeleteEmp(string Id)
    {
        string query = String.Format("delete from EMPLOYEES where ID={0}", Id);
        return RunDML(query);
    }

    
    public static DataTable SearchEmp(string Field, string value)
    {
        string query = String.Format("select * from EMPLOYEES where {0} like '%{1}%'", Field, value);
       return RunSelect(query);
    }

    public static DataTable Login(User user)
    {
        string query = "select * from LOGIN where USERNAME='" + user.UserName + "' AND PASSWORD='" + user.Password + "' AND CENTER='" + user.Center + "' AND LOGINAS='" + user.Job + "' ";
        return RunSelect(query);
    }
}